package com.yingsheng.bi.hks.service.storesdetail;

import com.yingsheng.bi.hks.bo.StoresDetailBo;
import com.yingsheng.bi.hks.dto.storedetail.*;
import com.yingsheng.bi.hks.mapping.StoresDetailMgmtMappings;
import com.yingsheng.bi.hks.repository.dao.po.StoreDetail;
import com.yingsheng.bi.hks.repository.dao.service.StoresDetailDaoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class StoresDetailMgmtService {

    @Autowired
    private StoresDetailDaoService storesDetailDaoService;

    /**
     * 收件信息新增
     * @param req
     * @return
     */
    public StoresDetailAddRes add(StoresDetailAddReq req) {
        StoreDetail storeDetail = StoresDetailMgmtMappings.INSTANCE.addReq2po(req);
        storesDetailDaoService.insert(storeDetail);
        return new StoresDetailAddRes();
    }

    public StoresDetailModRes mod(StoresDetailModReq req) {
        StoreDetail storeDetail = StoresDetailMgmtMappings.INSTANCE.addReq2po(req);
        storesDetailDaoService.updateById(storeDetail);
        return new StoresDetailModRes();
    }

    public StoresDetailQryRes qry(StoresDetailQryReq req) {
        List<StoreDetail> list = storesDetailDaoService.query(req);
        List<StoresDetailBo> addrList = StoresDetailMgmtMappings.INSTANCE.storesDetailList2boList(list);
        StoresDetailQryRes res = new StoresDetailQryRes();
        res.setStoresDetailBoList(addrList);
        return res;
    }

    public StoresDetailDelRes del(StoresDetailDelReq req) {
        storesDetailDaoService.del(req.getId());
        StoresDetailDelRes res = new StoresDetailDelRes();
        return res;
    }
}
